// pages/searchPage/index.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        searchInfo: "",
        checkedListInfo: [
            {
                id: 1,
                imageUrl: "https://www.zhifure.com/upload/icons/2018/5/1717384956.jpg",
                title: "红富士苹果",
                price: 46,
                oldPrice: 90
            }
        ],
        checkedListName: "商品",
        goodsList: [
            {
                id: 1,
                imageUrl: "https://www.zhifure.com/upload/icons/2018/5/1717384956.jpg",
                title: "红富士苹果",
                price: 46,
                oldPrice: 90
            }
        ],
        articleList: [
            {
                id: 1,
                imageUrl: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F017a965bc81f61a8012099c8deb8b8.png%402o.png&refer=http%3A%2F%2Fimg.zcool.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1640738402&t=8df147d81667ca0f72b05b252975b488",
                title: "苹果原来还能这么吃！",
                author: "惠农汇官方推送",
                like: 156
            }
        ]
    },

    // 切换分类
    switchTabList(e) {
        console.log(e)
        const id = e.currentTarget.id
        const type = e.currentTarget.dataset["listtitle"]
        var tabListInfo = []
        if (type === "商品") {
            tabListInfo = this.data.goodsList
        } else if (type === "文章") {
            tabListInfo = this.data.articleList
        }

        this.setData({
            checkedListName: type,
            checkedListInfo: tabListInfo
        })
    },

    //页面内搜索值
    searchSet(e) {
        this.setData({
            searchInfo: e.detail
        })
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var searchInfo = options.searchInfo
        this.setData({
            searchInfo: searchInfo
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})